<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncEZComments.php,v $
 * $Author: landseer $
 * $Revision: 1.2 $
 * $Date: 2004/08/09 13:45:42 $
 *
 * Type: Function
 *
 * allows the users t post a comment to an item using EZComments
 *@param params['ItemID'] int the id of the item
 *@return string processed smarty output
 */
function smarty_function_pncEZComments($params, &$smarty)
{
    extract($params);

    if( !$ItemID )
    {
        $smarty->trigger_error( "pncEZComments: missing parameter ItemID" );
    }
    
    if( !pnModAPILoad( 'pncommerce', 'user' ) )
    {
        $smarty->trigger_error( 'pncEZComments: cannot load pncommerce userapi', E_ERROR ); 
        return false;
    }

    if( !pnModLoad( 'EZComments', 'user' ) )
    {
        // silently return
        return false;
    }
    $url = pnModAPIFunc( 'pncommerce', 'user', 'pncModURL', array( 'Module'   => 'pncommerce',
                                                                   'Section'  => 'user',
                                                                   'Function' => 'itemview',
                                                                   'Args'     => array( 'ItemID' => $ItemID ) ) );
    return pnModFunc( 'EZComments', 'user', 'view', array( 'objectid' => $ItemID,
                                                           'extrainfo' => $url  ) );

}
?>
